/**
 * @author: Xzh
 * @date: 2023/3/2 18:08
 * @description:
 *
 * 问题总结 return 没有结束方法
 */
public class figureTest {
    public static void main(String[] args) {
        figureTest figureTest = new figureTest();
//        figureTest.requirement("直角三角形",0,6,"+");
//        figureTest.requirement("等边三角形",1,6,"+");
//        figureTest.requirement("梯形",0,6,"+");
//        figureTest.requirement("等腰梯形",0,6,"+");
//        figureTest.requirement("菱形",0,6,"+");
//        figureTest.requirement("乘法口诀",0,6,"+");
        figureTest.requirement("乘法口诀",1,6,"+");
        figureTest.requirement("正方形",0,6,"+");

    }

    /**
     * 需求接口
     * @param figure 形状
     * @param direction 方向 0 向上 1 向下
     * @param max  最大边
     * @param sType 打印字符串类型
     */
    public void requirement(String figure,Integer direction,Integer max,String sType){
        if(figure.equals("直角三角形")){
            this.delta(direction,max,sType);
            return;
        }
        if(figure.equals("等边三角形")){
            this.equalDelta(direction,max,sType);
            return;
        }
        if(figure.equals("等边三角形")){
            this.equalDelta(direction,max,sType);
            return;
        }
        if(figure.equals("梯形")){
            this.ladderType(direction,max,sType);
            return;
        }
        if(figure.equals("等腰梯形")){
            this.equalLadderType(direction,max,sType);
            return;
        }
        if(figure.equals("菱形")){
            this.rhomb(direction,max,sType);
            return;
        }
        if(figure.equals("乘法口诀")){
            this.multiplicationMathod(direction,max,sType);
            return;
        }
        if(figure.equals("正方形")){
            this.square(direction,max,sType);
            return;
        }
    }

    /**
     * 正方形
     * @param direction
     * @param max
     * @param sType
     */
    private void square(Integer direction, Integer max, String sType) {
        if(direction instanceof Integer) {
            for (int i = 1; i <=max; i++) {
                for (int j = 1; j <=max; j++) {
                    System.out.print(sType+" ");
                }
                System.out.println();
            }
        }
    }

    /**
     * 乘法口诀
     * @param direction
     * @param max
     * @param sType
     */
    private void multiplicationMathod(Integer direction, Integer max, String sType) {
        if(direction==0){
            for (int i = 1; i <= max; i++) {
                for (int j = 1; j <= i; j++) {
                    System.out.print(i + "*" + j + "=" + i * j + "\t");
                }
                System.out.println();
            }
        } else if (direction==1) {
            for (int i = max; i >= 1; i--) {
                for (int j = 1; j <= i; j++) {
                    System.out.print(i + "*" + j + "=" + i * j + "\t");
                }
                System.out.println();
            }
        }
    }

    /**
     * 菱形
     * @param direction
     * @param max
     * @param sType
     */
    private void rhomb(Integer direction, Integer max, String sType) {
        if (direction instanceof Integer){
            for (int i = 1; i <=max; i++) {
                //先打印空格
                for (int j = 1; j <= i; j++) {
                    System.out.print(" ");
                }
                //在打印三角形
                for (int y = max; y >= i; y--) {
                    System.out.print(sType);
                }
                //在打印三角形
                for (int m = 1; m <= i; m++) {
                    System.out.print(sType);
                }
                System.out.println();
            }
            return;
        }

    }

    /**
     * 等腰梯形
     * @param direction
     * @param max
     * @param sType
     */
    private void equalLadderType(Integer direction, Integer max, String sType) {
        if(direction instanceof Integer){
            //先打空格
            for (int i = 1; i <=max; i++) {
                for (int j = max; j >=i; j--) {
                    System.out.print(" ");
                }
                //在打印三角形
                for (int y = 1; y <=i; y++) {
                    System.out.print(sType);
                }
                for (int j = 1; j <=i; j++) {
                    System.out.print(" "+sType);
                }
                for (int j = max; j >=i; j--) {
                    System.out.print(sType+" ");
                }
                for (int j = 1; j <=i; j++) {
                    System.out.print(sType);
                }
                System.out.println();
            }
            return;
        }
    }

    /**
     * 梯形
     * @param direction
     * @param max
     * @param sType
     */
    private void ladderType(Integer direction, Integer max, String sType) {
        if(direction instanceof Integer){
            for (int i = 1; i <=max; i++) {
                //先打印正方形
                for (int j = 1; j <=max; j++) {
                    System.out.print(sType);
                }
                //在打印三角形
                for (int y = 1; y <=i; y++) {
                    System.out.print(sType);
                }
                System.out.println();
            }
            return;
        }
    }

    /**
     * 直角三角形
     * @param direction 方向
     * @param max  最大边
     * @param sType 打印字符串类型
     */
    public void delta(Integer direction,Integer max,String sType){
        if(direction==0){
            for (int i = 1; i <= max; i++) {
                for (int j = 1; j <= i; j++) {
                    System.out.print(sType);
                }
                System.out.println();
            }
            return;
        }
        if(direction==1){
            for (int i = 1; i <= max; i++) {
                for (int j = max; j >= i; j--) {
                    System.out.print(sType);
                }
                System.out.println();
            }
            return;
        }
    }

    /**
     * 等边三角形
     * @param direction
     * @param max
     * @param sType
     */
    public void equalDelta(Integer direction,Integer max,String sType){
        if(direction==1){
            for (int i = 1; i <=max; i++) {
                //先打印空格
                for (int j = 1; j <= i; j++) {
                    System.out.print(" ");
                }
                //在打印三角形加空格是为了变成等边三角形
                for (int y = max; y >= i; y--) {
                    System.out.print(" "+sType);
                }
                System.out.println();
            }
            return;
        }
        if(direction==0){
            for (int i = 1; i <=max; i++) {
                //先打印空格
                for (int j = max; j >= i; j--) {
                    System.out.print(" ");
                }
                //在打印三角形加空格是为了变成等边三角形
                for (int y = 1; y <= i; y++) {
                    System.out.print(" "+sType);
                }
                System.out.println();
            }
            return;
        }
    }
}
